/**
 * GetWebContent
 * 
 * 05/12/2013
 * 
 * Copyright GPL
 */
package com.jtmproject.javiertejedor.asynctasks;

import com.jtmproject.javiertejedor.activities.CipherActivity;
import com.jtmproject.javiertejedor.classes.StringsUtils;
import com.jtmproject.javiertejedor.web.GetCodeHtml;

import android.os.AsyncTask;

/**
 * This class gets the content of the html class
 * @author Javier Tejedor
 */
public class GetWebContent extends AsyncTask<String, String, String> {

	private CipherActivity activity;
	private String url;
	private String webContent;
	
	/**
	 * constructor
	 * @param url
	 */
	public GetWebContent(CipherActivity activity, String url){
		this.activity = activity;
		this.url = url;
		webContent = "";
	}
	
	/* (non-Javadoc)
	 * @see android.os.AsyncTask#doInBackground(java.lang.Object[])
	 */
	@Override
	protected String doInBackground(String... params) {
		
		webContent = new GetCodeHtml().codeHtml(this.url);
		
		return null;
	}

	/* (non-Javadoc)
	 * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
	 */
	@Override
	protected void onPostExecute(String result) {
		super.onPostExecute(result);
		
		if(!StringsUtils.geStringUtils().isStringVoid(webContent)) {
			activity.setTextResult(webContent);
		}
	}
}
